﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace ScarEngine
{
    public static class LevelManager
    {

        public static Dictionary<String, Level> Levels;
        public static Level CurrentLevel;
        


        public static void Init()
        {
            Levels = new Dictionary<string, Level>();
        }

        

        public static void UpdateLevel(GameTime gameTime)
        {
            CurrentLevel.Update(gameTime);
        }

        #region Add Level

        public static void AddLevel<LevelType>(string levelname) where LevelType : Level, new()
        {

            Levels.Add(levelname, new LevelType() as LevelType);

        }



        #endregion


        #region Change Level

        static void InitLevel()
        {
            CurrentLevel.Init();
            CurrentLevel.ContentLoad();
            CurrentLevel.BeginRun();
        }

        static void UnloadLevel()
        {
            CurrentLevel = null;
            MasterManager.GraphicsManager.ClearDrawList();
        }

        static void NewLevel<LevelType>() where LevelType : Level, new()
        {
            LevelType L = new LevelType();
            CurrentLevel = L;
        }

        public static void ChangeLevel(string level)
        {
            UnloadLevel();
            CurrentLevel = Levels[level];
            InitLevel();
        }

        #endregion




    }
}
